<?php defined('SYSPATH') OR die('No direct access allowed.');

class Blog_Controller extends Web_Controller {

  public $template = 'index';

  public function __construct() 
  {
      parent::__construct();
      //$this->db = new Database;
      $this->article = new Article_Model;
      /*$this->template->menus = array
      (
          'main' => array
          (
              'title'   =>  'Главная страница блога',
              'link'    =>  '/blog/',
          ),
          'article' => array
          (
              'title'   =>  'Статья "Наша первая страница на Kohana"',
              'link'    =>  '/2009/01/12/',
          ),
      );
      $this->template->content = '';*/
  }

  public function index()
  {
      url::redirect('blog/view_articles');
  }

  public function view_articles($id = NULL)
  {
      $this->template->content = new View('blog/articles');
      $this->template->title = 'Список статей';
      $this->template->content->articles = $this->article->get_articles($id);
  }

  public function view_article($id = NULL)
  {
      $this->template->title = 'Просмотр статьи';
      $this->template->content = new View('blog/article');
      $this->template->content->article = $this->article->get_article($id);
  }

}